package tools.icq.spam;

import core.Main;

/**
 *
 * @author dcrm
 */
public class TMessager implements Runnable {

    private Thread thread;
    private final String THREAD_NAME ="TMessanger";
    private int who;
    private String str;
    private int cnt;
    private String uin;
    private long time;
    private boolean req;
    
    public static final int TYPE_MSG = 0;
    public static final int TYPE_AUTH = 1;
    public static final int TYPE_AREC = 2;
    public static final int TYPE_ADD = 3;
    public static final int TYPE_REM = 4;
    private int type;


    public TMessager(String str, String uin, int cnt, long time, int who, int type, boolean rec) {
        this.str=str;
        this.uin=uin;
        this.cnt=cnt;
        this.time=time;
        this.who=who;
        this.type=type;
        this.req=rec;
        thread = new Thread(this);
        thread.setName(THREAD_NAME+"["+who+"->"+uin+"]");
        thread.start();
    }

    public TMessager(String str, String uin, int who, int type)
    { this(str, uin, 1, 0, who, type, false);}

    public TMessager(String str, String uin, int who, boolean req)
    { this(str, uin, 1, 0, who, TYPE_AUTH, req); }

    public void run() {
      try {
            for (int i=0;i<cnt;i++)
            {
                switch (type)
                {
                    case 0: Main.UIN_PRIMES.get(who).sendBasicMessage(str, uin); break;
                    //case 1: Main.UIN_PRIMES.get(who).sendAuthReplyMessage(str, uin, req); break;
                    //case 2: Main.UIN_PRIMES.get(who).sendAuthRequestMessage(str, uin); break;
                    //case 3: Main.UIN_PRIMES.get(who).sendYouWereAdded(uin); break;
                    //case 4: Main.UIN_PRIMES.get(who).removeYourself(uin); break;
                }
                Thread.sleep(time);
            }
            //if (F_DEBUG_MSG) {System.out.println("Send to:"+uin+"; "+str);};
        } catch (Exception ex) { ex.printStackTrace();}
    }

}
